﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="Eatime.Main.ItemDetailPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Eatime.Main"
    xmlns:data="using:Eatime.Main.Data"
    xmlns:common="using:Eatime.Main.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Entitys="using:Eatime.Entitys"
    mc:Ignorable="d">

    <Page.Resources>

        <!-- 此页所显示的项集合-->
        <CollectionViewSource
            x:Name="itemsViewSource"
            Source="{Binding Items}"
            d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"/>
    </Page.Resources>

    <!--
        此网格用作定义以下两行的页的根面板:
        * 第 0 行包含后退按钮和页标题
        * 第 1 行包含页布局的其余部分
    -->
    <Page.BottomAppBar >
        <AppBar x:Name="AppBarCollection"  Visibility="Visible">
            <Grid>
                <Button   x:Name="AppBarCollectionButton"  Style="{StaticResource FavoriteAppBarButtonStyle}"    AutomationProperties.Name="收藏" HorizontalAlignment="Center"/>
            </Grid>
        </AppBar>
    </Page.BottomAppBar>
    
    <Grid
        Style="{StaticResource LayoutRootStyle}"
        DataContext="{Binding Group}"
        d:DataContext="{Binding AllGroups[0], Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}">
        <Grid.Background>
            <ImageBrush ImageSource="Assets/background.png"/>
        </Grid.Background>

        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
      

        <!--
            此页的其余部分是一个较大的 FlipView，用于一次显示一个项的详细信息，
            并允许用户浏览所选组中的
            所有项
        -->
        
        <FlipView
            x:Name="flipView"
            AutomationProperties.AutomationId="ItemsFlipView"
            AutomationProperties.Name="Item Details"
            TabIndex="1"
            Grid.RowSpan="2">
            <FlipView.ItemContainerStyle>
                <Style TargetType="FlipViewItem">
                    <Setter Property="Margin" Value="0,137,0,0"/>
                </Style>
            </FlipView.ItemContainerStyle>

            <FlipView.ItemTemplate>
                <DataTemplate>

                    <!--
                        选定 UserControl 作为模板项的原因是它支持视觉状态管理
                        已加载/已卸载事件显式订阅该页中的视图状态更新
                    -->
                    <UserControl Loaded="StartLayoutUpdates" Unloaded="StopLayoutUpdates">
                        <ScrollViewer x:Name="scrollViewer" Style="{StaticResource HorizontalScrollViewerStyle}" Grid.Row="1">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="434"/>
                                    <ColumnDefinition Width="544"/>
                                    <ColumnDefinition Width="492"/>
                                </Grid.ColumnDefinitions>
                                <!-- 允许内容在所需的任意数量的列中流动-->
                                <Grid Height="580" Width="317"  Margin="117,0,0,30" Background="White">
                                    <StackPanel x:Name="Detailinfo"   VerticalAlignment="Top" Margin="5,0,5,0" >
                                        <TextBlock Text="{Binding Path=Shop.Title}" Grid.Column="1" FontSize="35" Margin="30,20,0,0" Foreground="Black"/>
                                        <Image x:Name="image" Height="254" Width="317" Source="{Binding Image}" Margin="5,20,5,10"  Stretch="Uniform"  AutomationProperties.Name="{Binding Title}"/>
                                        <ListBox ItemsSource="{Binding}">
                                            <ListBox.ItemsPanel>
                                                <ItemsPanelTemplate>
                                                    <StackPanel Orientation="Horizontal"/>
                                                </ItemsPanelTemplate>
                                            </ListBox.ItemsPanel>
                                            <ListBox.ItemTemplate>
                                                <DataTemplate>
                                                    <Image Source="{Binding}" Height="20" Width="20"/>
                                                </DataTemplate>
                                            </ListBox.ItemTemplate>
                                        </ListBox>
                                        <TextBlock FontWeight="SemiLight" Text="{Binding Path=Shop.Address}" Foreground="Black"  FontSize="16" Margin="20,10,0,0"/>
                                        <TextBlock FontWeight="SemiLight" Text="{Binding Path=Shop.Phone}" Foreground="Black" FontSize="16" Margin="20,10,0,0" />
                                        <StackPanel Orientation="Vertical"  Margin="20,0,0,0">
                                            <StackPanel   Orientation="Horizontal"  Margin="0,10,0,0">
                                                <TextBlock Text="口味"  FontSize="16" Foreground="Black"/>
                                                <Image Source="Assets/Articlecomments.png" Height="6" Width="124"/>
                                            </StackPanel>
                                            <StackPanel   Orientation="Horizontal"  Margin="0,10,0,0">
                                                <TextBlock Text="服务" FontSize="16" Foreground="Black"/>
                                                <Image Source="Assets/Articlecomments.png" Height="6" Width="124"/>
                                            </StackPanel>
                                            <StackPanel   Orientation="Horizontal"  Margin="0,10,0,0">
                                                <TextBlock Text="环境"  FontSize="16" Foreground="Black"/>
                                                <Image Source="Assets/Articlecomments.png" Height="6" Width="124"/>
                                            </StackPanel>
                                        </StackPanel >
                                        <TextBlock Text="推荐菜：红烧鲤鱼、红烧肉、麻婆豆腐、宫保鸡丁" Margin="20,10,0,0"  Foreground="Black" FontSize="16" TextWrapping="Wrap"/>
                                    </StackPanel>
                                </Grid>
                              
                                
                                <Grid Height="580"  Grid.Column="1" Margin="16,0,0,30" Background="White">

                                    <TextBlock Text="菜谱  >" Grid.Column="1" FontSize="35" Margin="30,20,0,0" Foreground="Black"  Tapped="TextBlock_Tapped_1"/>
                                
                                    <GridView Grid.Column="1" Margin="5,60,5,0" 
                                                        ItemsSource="{Binding Items}"
                                                        x:Name="itemGridView"
                                                         AutomationProperties.AutomationId="ItemGridView"
                                                         AutomationProperties.Name="Items In Group"
                                                         TabIndex="1"
                                                         Grid.RowSpan="2"
           
                                                         SelectionMode="None"
                                                          IsSwipeEnabled="false">
                               
                                        <GridView.ItemContainerStyle>
                                            <Style TargetType="FrameworkElement">
                                                <Setter Property="Margin" Value="0,0,0,0"/>
                                            </Style>
                                        </GridView.ItemContainerStyle>
                                        <GridView.ItemTemplate>
                                            <DataTemplate>
                                                <Grid Height="125" Width="160">
                                                    <Image  Source="Assets/TextImage/cp.png"  Height="125" Width="160"/>
                                                    <Border VerticalAlignment="Bottom" Background="Black" Opacity="0.6"/>
                                                    <TextBlock Text="{Binding Title}" HorizontalAlignment="Left" Margin="5,0,0,5" VerticalAlignment="Bottom" FontSize="18">
                                                    </TextBlock>
                                                    <TextBlock Text="{Binding Price}" HorizontalAlignment="Right" Margin="0,0,5,5" VerticalAlignment="Bottom" FontSize="18">
                                                    </TextBlock>
                                                </Grid>
                                            </DataTemplate>
                                        </GridView.ItemTemplate>

                                      
                                    </GridView>
                                </Grid>
                                <Grid Height="580"  Grid.Column="2" Margin="16,0,0,30" Background="White">
                                    <TextBlock Text="评论" Grid.Column="1" FontSize="35" Margin="30,20,0,0" Foreground="Black"/>
                                    <GridView ItemsSource="{Binding Path=ShopReviewDatas.Rows}" x:Name="ShopReviewGridView" Grid.Column="2" Height="600"  Margin="30,60,0,0">
                                        <GridView.ItemTemplate>
                                            <DataTemplate>
                                                <Grid Margin="10">
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="58"/>
                                                        <ColumnDefinition Width="360"/>
                                                    </Grid.ColumnDefinitions>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="40"/>
                                                        <RowDefinition Height="60"/>
                                                    </Grid.RowDefinitions>
                                                    <Image Source="Assets/TextImage/Reviewhead.png" Grid.RowSpan="2" Height="59" VerticalAlignment="Center"/>
                                                    <TextBlock Text="吃货王子" Grid.Column="1" Grid.Row="0" Foreground="Black" Margin="10" VerticalAlignment="Center"/>
                                                    <TextBlock Text="{Binding ReviewContent}" Grid.Column="1" Grid.Row="1" Margin="10,0,0,0" TextWrapping="Wrap" Foreground="Black" VerticalAlignment="Center"/>
                                                </Grid>
                                            </DataTemplate>
                                        </GridView.ItemTemplate>
                                       

                                    </GridView>
                                </Grid>

                         </Grid>
                            <VisualStateManager.VisualStateGroups>

                                <!-- 视觉状态反映应用程序在 FlipView 内部的视图状态-->
                                <VisualStateGroup x:Name="ApplicationViewStates">
                                    <VisualState x:Name="FullScreenLandscape"/>
                                    <VisualState x:Name="Filled"/>

                                    <!-- 采用较窄的 100 像素页边距约定(纵向)-->
                                    <VisualState x:Name="FullScreenPortrait">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="richTextColumns" Storyboard.TargetProperty="Margin">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="97,0,87,57"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="image" Storyboard.TargetProperty="MaxHeight">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="400"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>

                                    <!-- 对齐后，将重新设置内容格式并将垂直滚动 -->
                                    <VisualState x:Name="Snapped">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="richTextColumns" Storyboard.TargetProperty="Margin">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="17,0,17,57"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="scrollViewer" Storyboard.TargetProperty="Style">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource VerticalScrollViewerStyle}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="richTextBlock" Storyboard.TargetProperty="Width">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="280"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="image" Storyboard.TargetProperty="MaxHeight">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="160"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                        </ScrollViewer>
                    </UserControl>
                </DataTemplate>
            </FlipView.ItemTemplate>
        </FlipView>

        <!-- 后退按钮和页标题-->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Text="{Binding Title}" Style="{StaticResource PageHeaderTextStyle}" Grid.Column="1" IsHitTestVisible="false" Foreground="Black"/>
        </Grid>
        <!--<Button Foreground="Black"   Height="60" Width="200" Content="shoucang" Margin=" 200,0,0,0" Click="Button_Click_1" Background="Red"/>-->
        <VisualStateManager.VisualStateGroups>

            <!-- 视觉状态反映应用程序的视图状态-->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- 后退按钮将采用较窄的 100 像素页边距约定(纵向)-->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- 对齐后，后退按钮和标题的样式将有所不同-->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
